* ANES analysis for: 
* Class, Policy Attitudes and U.S. Presidential Voting in the Post-Industrial Era: The Importance of Issue Salience
* Franko & Witko
* Political Research Quarterly
* Date: 05/25/22


*****************************************************************************
* Data setup.		 														*
*****************************************************************************


* Recode some variables, try to make similar to GSS.
gen inc5 = VCF0114
gen pid7 = VCF0301
recode pid7 (1 2 3 = 1) (4 = 2) (5 6 7 = 3), gen(pid3)
recode pid7 (1 2 = 1) (3 4 5 = 2) (6 7 = 3), gen(pid3b)
recode VCF0803 (9 = .), gen(polviews)
gen subclass = VCF0148
recode VCF0104 (2 = 1) (1 = 0) (3 . = 0), gen(female)
recode VCF0105a (1 = 1) (else = 0), gen(white)
gen age = VCF0101
* GSS asks about "number of years completed," not specific degrees/level 
* of schooling.
recode VCF0140 (1 = 1) (2 = 2) (3/4 = 3) (5 = 4) (6 = 5), gen(edu5)

* Combine some EGP categories with small sample sizes.
recode egp10_10 (11 = 10) (12 = .), gen(egp10_alt)
  label define egp10alt 1 "I" 2 "II" 3 "IIIa" 4 "IIIb" 7 "IVc" ///
  8 "V" 9 "VI" 10 "VIIab"
  label values egp10_alt egp10alt
tab egp10_alt, gen(egp10_alt)
* Variations of EGP with fewer categories.
recode egp10_10 (1 2 = 1) (3 = 2) (4 = 3) (7 = .) (8 9 10 11 = 4) (12 = .), gen(egp4)
recode egp10_10 (1 2 = 1) (3 = 2) (4 = 3) (7 = .) (8 = 4) (9 10 11 = 5) (12 = .), gen(egp5)

tab egp5, gen(egp5_)

* Create jobs variable. 
recode VCF0809 (7=1) (6=2) (5=3) (4=4) (3=5) (2=6) (1=7) (9=.), gen(guarantee_jobs)
* Rescale so variable is 0 to 1.
gen jobs01 = (guarantee_jobs - 1) / 6

* Create vote choice variable.
recode VCF0704a (1 = 1) (2 = 0), gen(demvote) 


* Aid to blacks.
recode VCF0830 (9 = .), gen(aidblk)
gen racepol01 = ((aidblk * -1) + 7) / 6

* Abortion.
recode VCF0838 (9 = .), gen(abor)
gen abor01 = (abor - 1) / 3

* Gay rights.
recode VCF0876 (1 = 1) (5 = 0) (8 = .), gen(gayr01)

* Abortion + gay rights.
gen culpol01 = (abor01 + gayr01) / 2


* Region.
clonevar region = VCF0112
recode region (3 = 1) (1 2 4 = 0), gen(south)


* Add numeric values to labels.
numlabel , add force


* Find years where variables are non-missing.
tabstat demvote jobs01 culpol01 racepol01 subclass egp5_1-egp5_5 inc5 edu5 pid7 polviews white age female south, by(year)

* Summary statistics.
* Save results to create tables later.
estpost sum demvote jobs01 culpol01 racepol01 subclass egp5_1-egp5_5 inc5 edu5 pid7 polviews white age female south if year >= 1972 & age >= 18
estimates store sum_anes

* Missing value patterns for class vars.
misstable pattern subclass inc5 edu5 egp5_1-egp5_5 if inlist(year, 1988, 1990, 1992, 1994, 2000, 2004) & age >= 18, asis

* Class vars correlations.
spearman subclass inc5 edu5 egp5_1-egp5_5 if year >= 1972 & age >= 18, pw



